﻿using System;
using System.Collections.Generic;
using System.Text;
using CyzFaceBLL.Common;

namespace CyzFaceBLL.Global
{
    public class GlobalParameters
    {
        /// <summary>
        /// 是否启用Mqtt消息中间件(Broker) 
        /// </summary>
        public static bool IsMQTTBroker { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public static string MQTTServer { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public static int MQTTPort { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public static string MQTTUserName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public static string MQTTPassWord { get; set; }

        public static void Init()
        {
            try
            {
                IsMQTTBroker = (Tool.GetAndAddConfig("IsMQTTBroker", "True").Trim().ToLower() == "true");
                MQTTServer = Tool.GetAndAddConfig("MQTTServer", "127.0.0.1");
                MQTTPort = 1883;
                try
                {
                    MQTTPort = int.Parse(Tool.GetAndAddConfig("MQTTPort", "1883"/*"1947"*/));
                }
                catch { }
                MQTTUserName = Tool.GetAndAddConfig("MQTTUserName", "admin");
                MQTTPassWord = Tool.GetAndAddConfig("MQTTPassWord", "123456");
            }
            catch(Exception ex)
            {
                LogWrite.TxtExport_DateNow("LogErr.txt", "GlobalParameters Init Err:" + ex.Message);
            }
        }

    }
}
